<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>样式</title>
    <script src="vue.js"></script>
    <style>
        .fontred{color: red}
    </style>
</head>
<body>
<div id="app">
    <div @click="handleDivClick"
         :class="{ fontred:isRed }">
        Hello world
    </div>
</div>
<script>
    var vm = new Vue({
        el:"#app",
        data:{
            isRed:false
        },
        methods:{
            handleDivClick:function () {
                this.isRed = !this.isRed
            }
        }
    });
</script>
</body>
</html>